Next | Prev | Up | Top | Contents | Index

Linking to Previously Built Dynamic Shared Objects

This section describes how to link your source files with previously built DSOs; for more information about how to build your own DSOs, see Chapter 3, "Using Dynamic Shared Objects."

To build an executable that uses a DSO, call a compiler driver just as you would for a non-shared library. For instance,

cc needle.c -lthread

This command links the resulting object file (needle.o) with the previously built DSO libthread.so (and the standard C DSO, libc.so.1), if available. If no libthread.so exists, but a PIC archive named libthread.a exists, that archive is used with libc.so.1, so you still get dynamic (run time) linking. Note that even .a libraries now contain position-independent code by default, though it is also possible to build non-shared .a libraries that do not contain PIC.


Next | Prev | Up | Top | Contents | Index